<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>轮播图</title>
    <style>
        #carousel {
            margin-left: auto;
            margin-right: auto;
            height: 270px;
            width: 480px;
        }

        #carousel>img {
            height: 270px;
            width: 480px;
            border-radius: 5px;
        }
    </style>
</head>

<body>
    <div id="carousel"><img src="../images/carousel_1.png" id="carousel_img"></div>
    <script>
        // 轮播图
        var imgObj = document.getElementById("carousel_img");
        var imgNum = 2
        setInterval(function () {
            if (imgNum > 5) imgNum = 1;
            imgObj.src = "../images/carousel_" + imgNum + ".png";
            imgNum++;
        }, 1000)
    </script>
</body>

</html>